<table class="w50" style="margin-bottom: 20px;">
	<tr>
		<td>
			<a href="<?=Request::$controller?>" class="awesome light-gray">&larr; to subscribers list</a>
		</td>
		<td>
			<a href="<?=Request::$controller?>message/" class="awesome green">+ add new message</a>
		</td>
	</tr>
</table>
<h1>Messages</h1>
<? if (count($messages)): ?>
<table class="w100 TableWithPadding TableWithBorder">
	<thead>
		<tr>
			<th class="w15">
				Date
			</th>
			<th class="w60">
				Subject
			</th>
			<th class="w15">
				Status
			</th>
			<th class="w10">
				Delete
			</th>
		</tr>
	</thead>
	<tbody>
		<? foreach ($messages as $message): ?>
			<tr>
				<td>
					<?=$message['dateTime']?>
				</td>
				<td>
					<? if ($message['status'] == ''): ?>
						<?=Html::anchor(Request::$controller . 'message/' . $message['id'] . '/', Html::chars($message['subject']))?>
					<? else: ?>
						<?=Html::chars($message['subject'])?>
					<? endif; ?>
				</td>
				<td>
					<?php
						switch ($message['status']) {
							case '':
								echo Html::anchor(Request::$controller . 'send/' . $message['id'] . '/', 'Send');
								break;
							case 'sent':
								echo 'Sent';
								break;
							case 'pending':
								echo 'In progress...';
								break;
						}
					?>
				</td>
				<td>
					<?=Html::anchor(Request::$controller.'removeMessage/' . $message['id'] . '/', '<img src="/images/icons/remove-user.png" />', array('onclick' => 'javascript:return confirm("Are you sure?")'))?>
				</td>
			</tr>
		<? endforeach; ?>
	</tbody>
</table>
<? else: ?>
<h2>No messages has been created yet.</h2>
<? endif; ?>
